<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<%@ include file="/module/orderField.jsp"%>

<style>

table label.error {
    margin-left: 5px;
    width: auto;
    display: inline;
    color: red;
}
</style>


<script>
$(document).ready(
					function() {
						$("#div1").dialog({
							width : 'auto',
							height : 'auto',
							bgiframe : true,
							modal : true,
							draggable : true,
							resizable : false,
							title : '选择老师',
							autoOpen : false,
						    buttons : {
						    '取消' : function() {
						    	$(this).dialog('close');
							},
							'确定' : function() {
								     var result = $.parseJSON('${studentListJson}');
							         var select = document.getElementById("toSelect");
							    	 var idsxm="";
							    	 var dbempids="";
							    	  for(j=0;j<select.length;j++){
								    		 for (var i = 0; i < result.length; i++) {
												    if(select[j].value==result[i].emid){
												    	if(idsxm.length>0)idsxm+="、";
												    	idsxm+="("+result[i].xm+","+result[i].zgh+")";
												    	if(dbempids.length>0)dbempids+="、";
												    	dbempids+="("+result[i].xm+","+result[i].zgh+","+result[i].emid+")";
													    break;
													}
												
									         }
								      } 
							    	  $("#dbxm").val(idsxm);
							    	  $("#dbempids").val(dbempids);
									
								  /*   if(num>=2){
								      layer.alert("只能选择一项", {icon: 6});
								      return false;
								    } */
								 /*  var str=$("#fromSelect").val()+"";
								  var strs = str.split(","); 
								  for(i=0;i<strs.length;i++){ */
									/*   if(i==0){ */
										/*   $("#dbempid").val(strs[i]); */
                                    /*   } */
									 /*  if(i==1){
										  $("#dbzgh").val(strs[i]);  
									  } */
								 /*  } */
								
						         //$("#dbxm").val($("#fromSelect").find("option:selected").text()); 
								  //$("#dbempid").val($("#fromSelect").val());
								  $(this).dialog('close');
							
							  
							  /* var mycars=$("#fromSelect").val();
							  var g= mycars.toString();
							  alert(g);
							  var strArry = mycars.split(',');
							  if(strArry.length>1){
								  alert("负责人只能选择一个");  
								  return false;
							  } */
							
							  
							}
						  }
						});

					});
	function showdiv() {
		$('#div1').dialog('open');
	}
</script>


</head>
<body>
     <form action="#" name="Form" id="Form" method="post">
        <input type="hidden" name="empid" id="empid"  value="${emid}"/>
		<table cellpadding="0" cellspacing="0" border="0" class="table-border" width="95%" >
			<tr>
				<td class="table-header" colspan="4">班主任顶班申请</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 15%">申请人姓名:</td>
				<td class="table-contentTD"  style="width: 35%">${xm}
				<input type="hidden" id="xm" name="xm"  placeholder="申请人姓名" value="${xm}"  autocomplete="off" maxlength="100"  readonly="readonly" class="required inputText" /></td>
		
			 <td class="table-titleTD" style="width: 15%">申请人工号:</td>
				<td class="table-contentTD" style="width: 35%">${zgh}
				<input type="hidden" name="zgh" id="zgh" placeholder="申请人工号"   value="${zgh}"  class="inputText"   readonly="readonly"  autocomplete="off"/></td>
			</tr>
			
			<tr>
				<td class="table-titleTD" style="width: 15%">申请日期:</td>
				<td class="table-contentTD"  style="width: 35%"><fmt:formatDate value="${applydate}" pattern="yyyy-MM-dd"/>
				<input type="hidden"  name="applydate1" id="applydate1"/></td>
			
				<td class="table-titleTD" style="width: 15%">状态:</td>
				<td class="table-contentTD"  style="width: 35%">
				<select id="states" name="states" class="selectList">
						<option value="0">未提交</option>
					<!-- 	<option value="1">审核中</option>
						<option value="2">审核通过</option>
						<option value="3">审核退回</option> -->
				</select></td>
			</tr>
		   
			 <tr>
				<td class="table-titleTD" style="width: 15%">顶班人:</td>
				<td class="table-contentTD"  colspan="3">
			    <input type="hidden" name="dbempids" id="dbempids"/>
				<input type="text" id="dbxm" name="dbxm" placeholder="顶班人" readonly="readonly" style="width:70%"   class="inputText"  autocomplete="off"/>&nbsp;&nbsp;
				<input type="button" id="optionBtn" value="选择" class="inputButton" onclick="javascript:showdiv();" />
				<input type="hidden" name="dbzgh" id="dbzgh" placeholder="顶班人工号"   class="inputText"  readonly="readonly"   autocomplete="off"/></td>
				</td>
				
			</tr>
			 <tr>
				<td class="table-titleTD" style="width: 15%"><font style="color: red;">*</font>顶班开始日期:</td>
				<td class="table-contentTD"  style="width: 35%">
				<input name="ksrq1" id="ksrq1" placeholder="顶班开始日期"   autocomplete="off"   
									class="Wdate required text inputText2" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></td>
			
				<td class="table-titleTD" style="width: 15%">开始日期范围:</td>
				<td class="table-contentTD"  style="width: 35%">
					   <input type="radio" value="上午" name="ksrqfw" checked="checked"/>上午
					   <input type="radio" value="下午" name="ksrqfw" />下午
				</td>
				
			</tr>
			
		     <tr>
				<td class="table-titleTD" style="width: 15%"><font style="color: red;">*</font>顶班结束日期:</td>
				<td class="table-contentTD"  style="width: 35%">
				<input name="jsrq1" id="jsrq1" placeholder="顶班结束日期"   autocomplete="off" 
									class="Wdate  required text inputText2" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></td>
									
				<td class="table-titleTD" style="width: 15%">结束日期范围:</td>
				<td class="table-contentTD" style="width: 35%">
					   <input type="radio" value="上午" name="jsrqfw" />上午
					   <input type="radio" value="下午" name="jsrqfw"  checked="checked"/>下午
				</td>
			</tr>
			
			<tr>
				<td class="table-titleTD"><font style="color: red;">*</font>顶班事由:</td>
				<td class="table-contentTD" colspan="3" ><textarea style="width: 90%;height: 80px;" name="reasons" id="reasons" placeholder="顶班事由" maxlength="2000" class="required "  ></textarea></td>
			</tr>
			<tr>
				<td class="table-titleTD">备注:</td>
				<td class="table-contentTD"  colspan="3"><textarea style="width: 90%;height: 80px;"  name="remark"  placeholder="备注" id="remark" maxlength="2000" ></textarea></td>
			</tr>
		</table>
	
		<br />
		
		<table cellpadding="1" cellspacing="1" border="0" align="left">
			<tr>
			   <kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId(\"XGGL_BJXX_BZRDB\")%>" key="add">		
			    <td><input type="button" id="btnSave" class="inputButton"
					style="text-align: center;" value="保存" /></td>
				<td><input type="button" id="btnSaveContinue" class="inputButton"
					style="text-align: center;" value="保存并新增" /></td>
				</kl:permission>		
				<td><input type="button" id="Cancel" class="inputButton"
					style="text-align: center;" value="取消" /></td>
				<td><input type="button" id="returnBut" class="inputButton"
					value="返回" style="text-align: center;" /></td>
			</tr>
		 </table>
		 </form> 
		 
		 
		  <div id="div1" style="display: none;">
					<table cellpadding="0" cellspacing="0" border="0"class="table-border">
					 <tr>
				  	 <td style="clear:both; width: 45%">
				  	   <input class="text" name="searchemp" ondblclick="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"  onkeyup="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"/><font color="green">在此查找</font> <br/>
				  	   <br/><label style="color:red;">未选择:</label><br/>
				  	   <select name="fromSelect" id="fromSelect"  class="inputText" multiple="multiple" style="width:220px; height: 300px;">
							ondblclick="moveField('fromSelect','toSelect');">
										  <c:forEach items="${List}" var="data">
										       <option value="${data.emid}">${data.xm}</option>
									          </c:forEach>
						</select>
						<select name="sourseFromSelect2" id="sourseFromSelect2" multiple="multiple" style="width: 220px; height: 150px; display: none;" >
						<option value="1">xxxx</option>
										<c:forEach items="${List}" var="data">
										       <option value="${data.emid}">${data.xm}</option>
									          </c:forEach>
				  	    </select>
				  	  </td>
				  	    <td align="center" style="width: 10%">
				  	    <input type="button" class="inputButton" onclick="moveAllField('fromSelect','toSelect');" style="width: 40px;" value=">>" /><br> <br/>
						<input type="button" class="inputButton" onclick="moveField('fromSelect','toSelect');" style="width: 40px;" value=">" /><br/><br/>
						<input type="button" class="inputButton"   style="width: 40px;" value="&lt" onclick="moveField('toSelect','fromSelect');"/><br/> <br/>
				     	<input type="button" class="inputButton" style="width: 40px;" onclick="moveAllField('toSelect','fromSelect');"  value="&lt&lt" />
				     </td>
				     <td style="width: 45%"><br/><br/><label style="color:red;">已经选中:</label><br/>
				     <select name="toSelect" id="toSelect" multiple="multiple"   class="inputText" selected="selected" style="width:220px;height: 300px;" ondblclick="moveField('toSelect','fromSelect');">
					 </select>
				    </td>	    
				  </tr>
				 </table>
	           </div>
            </div>
		 
		<%--   <div id="div1" style="display: none;">
			<table cellpadding="0" cellspacing="0" border="0" class="table-border">
				  <tr>
					  	 <td style="clear:both; width: 70%">
					  	  <input class="text" name="searchemp" ondblclick="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"  onkeyup="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"/><font color="green">在此查找</font> <br/>
					  	   <br/><label style="color:red;">未选中:</label><br/>
					  	   <select name="fromSelect" id="fromSelect" multiple="multiple"  size="1"  multiple="false" style="width:200px; height: 250px;"
								ondblclick="moveField('fromSelect','toSelect');">
												<c:forEach items="${List}" var="data">
										       <option value="${data.emid}">${data.xm}</option>
									          </c:forEach>
							</select>
								<select name="sourseFromSelect2" id="sourseFromSelect2"   multiple="false" style="width: 220px; height: 150px; display: none;" >
											  <c:forEach items="${List}" var="data">
										       <option value="${data.emid}">${data.xm}</option>
									          </c:forEach>
	  	                        </select>
						  </td>
  	              </tr>
			</table>
	    </div> --%>
		
		<script>
		    

		
			$(document).ready(function() {
				var _form=$("#Form").validate();
				$("#btnSave").click(function() {
					if(_form.form()){
						  var beginTime=$("#ksrq1").val();
                         var endTime=$("#jsrq1").val();
                         if(beginTime!=""&& beginTime>endTime){
	       					     layer.alert('顶班开始时间不能大于顶班结束时间!', {icon: 5});
							     return false;
                          }
                          if(endTime!=""&& endTime<beginTime){
                       	     layer.alert('顶班结束时间不能大于顶班开始时间!', {icon: 5});
							     return false;
                          } 
						validataSave();
					}
				});
				
				$("#btnSaveContinue").click(function() {
					if(_form.form()){
						 var beginTime=$("#ksrq1").val();
                          var endTime=$("#jsrq1").val();
                          if(beginTime!=""&& beginTime>endTime){
	       					     layer.alert('顶班开始时间不能大于顶班结束时间!', {icon: 5});
							     return false;
                           }
                           if(endTime!=""&& endTime<beginTime){
                        	     layer.alert('顶班结束时间不能大于顶班开始时间!', {icon: 5});
							     return false;
                           } 
						  validataSaveContinue();
					}
				});
				
				
				$("#returnBut").click(function() {
		 			   window.location.href='${basePath}/bjxxClassWorkInstead/index_bzr';
		 		});
				
				$("#Cancel").click(function() {
					   window.location.href = "${basePath}/bjxxClassWorkInstead/addInInt";
		 		});
			});
			
			
			function validataSave(){
				  /* 	$.ajax({
						  type: 'POST',
						  url: "${basePath}/bjxxClassWorkInstead/validation",
					      data:{xmmc : $('#xmmc').val(),id:null},
						  success:function(data){
						   if(data.msg=="-99"){
							     layer.alert('服务器异常', {icon: 5});
							     return false;
						   }else if(data.msg!='0'){
							     layer.alert('申请人名称已经存在请重新输入', {icon: 5});
							     return false;
						   }else{ */
							    document.Form.action ="${basePath}/bjxxClassWorkInstead/add";
								document.Form.submit();
						  /*  }   
						  }
						});	 */
				}
				
				
				function validataSaveContinue(){
				  /* 	$.ajax({
						  type: 'POST',
						  url: "${basePath}/bjxxClassWorkInstead/validation",
					      data:{xmmc : $('#xmmc').val(),id:null},
						  success:function(data){
						   if(data.msg=="-99"){
							     layer.alert('服务器异常', {icon: 5});
							     return false;
						   }else if(data.msg!='0'){
							     layer.alert('申请人名称已经存在请重新输入', {icon: 5});
							     return false;
						   }else{ */
							    document.Form.action ="${basePath}/bjxxClassWorkInstead/addSaveContinue";
								document.Form.submit();
						 /*   }   
						  }
						});	 */
				}
			
			 if("${msg}"!=""){
			       layer.alert("${msg}", {icon: 6});
			  } 
		</script>
</body>
</html>
